var { clickContent, randomUtils } = require("../../utils/index");
var ad = require("../../ads/douYin/index");
var TypeEnum = {
  立即签到: "lijiqiandao",
  看广告: "kanguanggao",
  开心收下: "kaixinshouxia",
  好的: "haode",
};
module.exports = {
  init(type) {
    if (type != TypeEnum.立即签到) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      if (this.checkSign()) {
        return;
      }
    }
    if (type != TypeEnum.看广告) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      if (this.checkAd()) {
        return true;
      }
    }
    if (type != TypeEnum.开心收下) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      if (this.checkOver()) {
        return;
      }
    }
    if (type != TypeEnum.好的) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      if (this.checkHaoDe()) {
        return;
      }
    }
  },
  checkHaoDe() {
    var content = "好的";
    if (clickContent(content)) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      this.init(TypeEnum.好的);
      return true;
    }
    return false;
  },
  checkOver() {
    var content = "开心收下";
    if (clickContent(content)) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      this.init(TypeEnum.开心收下);
      return true;
    }
    return false;
  },
  checkAd() {
    var content = "看广告视频再赚";
    if (clickContent(content)) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      ad.startWatchAd();
      this.init(TypeEnum.看广告);
      return true;
    }
    return false;
  },
  checkSign() {
    var content = "立即签到";
    if (clickContent(content)) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      var content = "好的";
      if (clickContent(content)) {
        sleep(randomUtils.getRandom(1.5, 3, 1000));
      }
      this.init(TypeEnum.立即签到);
      return true;
    }
    var content = "签到得";
    if (clickContent(content)) {
      sleep(randomUtils.getRandom(1.5, 3, 1000));
      var content = "好的";
      if (clickContent(content)) {
        sleep(randomUtils.getRandom(1.5, 3, 1000));
      }
      this.init(TypeEnum.立即签到);
      return true;
    }
    return false;
  },
};
